﻿<!DOCTYPE HTML>
<html>
<head>
	<meta charset="utf-8">
	<meta name="renderer" content="webkit|ie-comp|ie-stand">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
	<meta http-equiv="Cache-Control" content="no-siteapp" />
	<link rel="Bookmark" href="/admin/imgs/logo.ico"/>
	<link rel="Shortcut Icon" href="/admin/imgs/logo.ico"/>
	<link rel="stylesheet" type="text/css" href="static/h-ui/css/H-ui.min.css" />
	<link rel="stylesheet" type="text/css" href="static/h-ui.admin/css/H-ui.admin.css" />
	<link rel="stylesheet" type="text/css" href="lib/Hui-iconfont/1.0.8/iconfont.css" />
	<link rel="stylesheet" type="text/css" href="static/h-ui.admin/skin/default/skin.css" id="skin" />
	<link rel="stylesheet" type="text/css" href="static/h-ui.admin/css/style.css" />
	<title>大会后台</title>
	<style type="text/css">
		a { color: #0088CC; }
		a.del { color: red; }
	</style>

	<script type="text/javascript" src="lib/jquery/1.9.1/jquery.min.js"></script>
	<script type="text/javascript" src="js/admin.js"></script>
	<script type="text/javascript">
		var info = getLoginInfo();
		(function(){
			if (!info) {
				window.location.href = 'login.html';
			}
		})();
	</script>
</head>
<body>
<section class="Hui-article-box" style="position:absolute;top:0;left:0;">
	<nav class="breadcrumb" style="color:#888;">
		<i class="Hui-iconfont">&#xe67f;</i>
		<a href="main.html" class="maincolor">首页</a>
		<span class="c-gray en">&gt;</span>
		前台
		<span class="c-gray en">&gt;</span>
		学术委员会
	</nav>
	<div class="Hui-article" style="position:absolute;top:20px;">
		<article class="cl pd-20">
			<div class="cl pd-5 bg-1 bk-gray mt-20">
				<span class="l">
					<a class="btn btn-primary radius" href="learnAdd.html">
						<i class="Hui-iconfont">&#xe600;</i> 添加
					</a>
				</span>
			</div>
			<div class="mt-20">
				<table class="table table-border table-bordered table-bg table-hover table-sort">
					<thead>
						<tr class="text-c">
							<th>ID</th>
							<th>标题</th>
							<th>图片</th>
							<th>操作</th>
						</tr>
					</thead>
					<tbody>
					</tbody>
				</table>
			</div>
		</article>
	</div>
</section>

<span id="pop"></span>
</body>
</html>

<script type="text/javascript">
	(function(){
		getIndex();
	})();
	//获取数据
	function getIndex(){
		var formData = {
		};
		$.ajax({
			type: 'post',
			url: domain+'learn/index',
			data: formData,
			success: function (res) {
			    res = JSON.parse(res);
			     console.log(res);
			    if (res.code!=0) {
			    	var tr = '<tr class="text-c"><td colspan="10">没有记录</td></tr>';
					$('tbody').html(tr); return
			    }
				var d = res.data;
				var h = '', id;
				for (var i=0; i<d.length; i++) {
					id = d[i].id;
					h += '<tr class="text-c">';
					h += '<td>'+(i+1)+'</td>';
					h += '<td>'+d[i].title+'</td>';
					h += '<td><img src="'+d[i].img+'" height="50"/></td>';
					h += '<td class="f-14 td-manage">';
					h += '<a href="javascript:;" class="ml-5" onClick="toEdit('+id+')">修改</a> &nbsp; ';
					h += '<a href="javascript:;" class="ml-5 del" onClick="toDel('+id+')">删除</a>';
					h += '</td>';
					h += '</tr>';
				}
				$('tbody').html(h);
			},
			error: function () {
			    console.log('网络异常');
			    pop({msg:'网络异常'});
			}
		});
	}
	//去修改
	function toEdit(id){
		window.location.href = 'learnEdit.html?id='+id;
	}
	//去删除
	function toDel(id){
		$.ajax({
			type: 'post',
			url: domain+'learn/del',
			data: {id: id},
			success: function (res) {
			    console.log(res);
			    res = JSON.parse(res);
			    if (res.code) {
			    	pop({msg:res.msg}); return
			    }
			    pop({msg:'成功'});
			    setTimeout(function(){
			    	window.location.href = '';
			    },2000);
			},
			error: function () {
			    console.log('网络异常');
			    pop({msg:'网络异常'});
			}
		});
	}
</script>